<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <title>Hoodoo::ErrorDescriptions::DomainDescriptions</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <link rel="stylesheet" href="../../../css/reset.css" type="text/css" media="screen" />
<link rel="stylesheet" href="../../../css/main.css" type="text/css" media="screen" />
<link rel="stylesheet" href="../../../css/github.css" type="text/css" media="screen" />
<script src="../../../js/jquery-1.3.2.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../../js/jquery-effect.js" type="text/javascript" charset="utf-8"></script>
<script src="../../../js/main.js" type="text/javascript" charset="utf-8"></script>
<script src="../../../js/highlight.pack.js" type="text/javascript" charset="utf-8"></script>

</head>

<body>
    <div class="banner">
        <h1>
            <span class="type">Class</span>
            Hoodoo::ErrorDescriptions::DomainDescriptions
                <span class="parent">&lt;
                    Object
                </span>
        </h1>
        <ul class="files">
            <li><a href="../../../files/lib/hoodoo/errors/error_descriptions_rb.html">lib/hoodoo/errors/error_descriptions.rb</a></li>
        </ul>
    </div>
    <div id="bodyContent">
        <div id="content">
    <div class="description">
      
<p>Contain a description of errors for a particular domain, where the domain
is a grouping string such as “platform”, “generic”, or a short service
name. Usually driven via <a
href="../ErrorDescriptions.html">Hoodoo::ErrorDescriptions</a>, not
directly.</p>

    </div>








    <!-- Method ref -->
    <div class="sectiontitle">Methods</div>
    <dl class="methods">
        <dt>E</dt>
        <dd>
          <ul>
              <li>
                <a href="#method-i-error">error</a>
              </li>
          </ul>
        </dd>
        <dt>N</dt>
        <dd>
          <ul>
              <li>
                <a href="#method-c-new">new</a>
              </li>
          </ul>
        </dd>
    </dl>








      <!-- Section attributes -->
      <div class="sectiontitle">Attributes</div>
      <table border='0' cellpadding='5'>
          <tr valign='top' id='attribute-i-descriptions'>
            <td class='attr-rw'>
              [R]
            </td>
            <td class='attr-name'>descriptions</td>
            <td class='attr-desc'><p>Hash of all descriptions, keyed by full error code, with options hash data
as values (see <a href="DomainDescriptions.html#method-i-error">error</a>
for details).</p></td>
          </tr>
          <tr valign='top' id='attribute-i-domain'>
            <td class='attr-rw'>
              [R]
            </td>
            <td class='attr-name'>domain</td>
            <td class='attr-desc'><p>Domain name for this description instance (string).</p></td>
          </tr>
      </table>


    <!-- Methods -->
      <div class="sectiontitle">Class Public methods</div>
        <div class="method">
          <div class="title method-title" id="method-c-new">
              <b>new</b>( domain )
            <a href="../../../classes/Hoodoo/ErrorDescriptions/DomainDescriptions.html#method-c-new" name="method-c-new" class="permalink">Link</a>
          </div>

            <div class="description">
              <p>Initialize a new instance for the given domain.</p>
<dl class="rdoc-list note-list"><dt>domain
<dd>
<p>The domain string - for most service-based callers, usually a short service
name like <code>members</code> or <code>transactions</code>.</p>
</dd></dl>
            </div>



            <div class="sourcecode">
              <p class="source-link">
                Source:
                <a href="javascript:toggleSource('method-c-new_source')" id="l_method-c-new_source">show</a>
              </p>
              <div id="method-c-new_source" class="dyn-source">
                <pre><span class="ruby-comment"># File lib/hoodoo/errors/error_descriptions.rb, line 184</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">initialize</span>( <span class="ruby-identifier">domain</span> )
  <span class="ruby-ivar">@domain</span>       = <span class="ruby-identifier">domain</span>
  <span class="ruby-ivar">@descriptions</span> = {}
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
          </div>
      <div class="sectiontitle">Instance Public methods</div>
        <div class="method">
          <div class="title method-title" id="method-i-error">
              <b>error</b>( name, options )
            <a href="../../../classes/Hoodoo/ErrorDescriptions/DomainDescriptions.html#method-i-error" name="method-i-error" class="permalink">Link</a>
          </div>

            <div class="description">
              <p>Describe an error.</p>
<dl class="rdoc-list note-list"><dt>name
<dd>
<p>The error name - the bit after the “<code>.</code>” in the code, e.g.
<code>invalid_parameters</code>.</p>
</dd><dt><code>options</code>
<dd>
<p>Options hash. See below.</p>
</dd></dl>

<p>The options hash contains symbol keys named as follows, with values as
described:</p>
<dl class="rdoc-list note-list"><dt><code>:status</code>
<dd>
<p>The integer or string HTTP status code to be associated with this error</p>
</dd><dt><code>message</code>
<dd>
<p>The <code>en-nz</code> language human-readable error message used for
developers.</p>
</dd><dt><code>reference</code>
<dd>
<p>Optional array of required named references. When errors are added (via <a
href="../Errors.html#method-i-add_error">Hoodoo::Errors#add_error</a>) to a
collection, required reference(s) from this array must be provided by the
error-adding caller else an exception will be raised. This ensures correct,
fully qualified error data is logged and sent to clients.</p>
</dd></dl>
            </div>



            <div class="sourcecode">
              <p class="source-link">
                Source:
                <a href="javascript:toggleSource('method-i-error_source')" id="l_method-i-error_source">show</a>
              </p>
              <div id="method-i-error_source" class="dyn-source">
                <pre><span class="ruby-comment"># File lib/hoodoo/errors/error_descriptions.rb, line 212</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">error</span>( <span class="ruby-identifier">name</span>, <span class="ruby-identifier">options</span> )
  <span class="ruby-identifier">options</span>       = <span class="ruby-constant">Hoodoo</span><span class="ruby-operator">::</span><span class="ruby-constant">Utilities</span>.<span class="ruby-identifier">stringify</span>( <span class="ruby-identifier">options</span> )
  <span class="ruby-identifier">required_keys</span> = [ <span class="ruby-string">&#39;status&#39;</span>, <span class="ruby-string">&#39;message&#39;</span> ]

  <span class="ruby-identifier">reference</span>              = <span class="ruby-identifier">options</span>[ <span class="ruby-string">&#39;reference&#39;</span> ]
  <span class="ruby-identifier">options</span>[ <span class="ruby-string">&#39;reference&#39;</span> ] = <span class="ruby-identifier">reference</span>.<span class="ruby-identifier">map</span>( <span class="ruby-operator">&amp;</span><span class="ruby-value">:to_s</span> ) <span class="ruby-keyword">if</span> <span class="ruby-identifier">reference</span>.<span class="ruby-identifier">is_a?</span>( <span class="ruby-operator">::</span><span class="ruby-constant">Array</span> )

  <span class="ruby-identifier">required_keys</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span> <span class="ruby-identifier">required_key</span> <span class="ruby-operator">|</span>
    <span class="ruby-keyword">unless</span> <span class="ruby-identifier">options</span>.<span class="ruby-identifier">has_key?</span>( <span class="ruby-identifier">required_key</span> )
      <span class="ruby-identifier">raise</span> <span class="ruby-node">&quot;Error description options hash missing required key &#39;#{ required_key }&#39;&quot;</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-ivar">@descriptions</span>[ <span class="ruby-node">&quot;#{ @domain }.#{ name }&quot;</span> ] = <span class="ruby-identifier">options</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
          </div>
</div>

    </div>
  </body>
</html>
